import {
    M_DETAIL_GOOD,A_DETAIL_INFO
} from '../types'
import {getData} from '../../services/getGoodData'
// 模块的state，放数据
const state = {
    bGood: false,
    goodInfo: null
}

// 处理业务
const actions = {
    // 获取详情数据
    [A_DETAIL_INFO]:async ({commit},payload)=>{
        let res = (await getData(payload)).data.data[0]
        commit(A_DETAIL_INFO, res)
    }
}

// 改变state状态
const mutations = {
    [M_DETAIL_GOOD]: (state, payload) => {
        state.bGood = payload
    },
    [A_DETAIL_INFO]: (state, payload) => {
        state.goodInfo = payload
    }
}

export default {
    namespaced: true, // 命名空间模块
    state,
    actions,
    mutations
}